
package com.probiz.estore.customer.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.probiz.estore.common.model.customer.Customer;
import com.probiz.estore.core.search.SearchCriteria;
import com.probiz.estore.customer.model.CustomerFullyModel;
import com.probiz.estore.customer.model.CustomerSearchCriteria;
import com.probiz.estore.system.service.AppUserManager;

public interface CustomerManager extends AppUserManager<Customer> {
	/**
	 * 搜索
	 * @param customerSearchCriteria
	 * @param searchCriteria
	 * @return
	 */
	public List<Customer> searchByCriteria(CustomerSearchCriteria customerSearchCriteria, SearchCriteria searchCriteria);
	
	 /**
     * 搜索，从GenericController借鉴过来。防止翻页过钱
     *
     * @param customerSearchCriteria 自定义搜索条件
     * @param searchCriteria        分页搜索条件
     * @return 搜索结果
     */
    public List<Customer> searchByCriteriaForController(CustomerSearchCriteria customerSearchCriteria, SearchCriteria searchCriteria);
	/**
	 * 根据客户id获得客户实体
	 * @param appUserId
	 * @return
	 */
	public Customer getByAppUserId(Integer appUserId);
	
	/**
	 * 根据用户名获取客户实体
	 * @param username
	 * @return
	 */
	public Customer getCustomerByUsername(String username);
	/**
	 * 根据email获取客户实体
	 * @param email
	 * @return
	 */
	public Customer getCustomerByEmail(String email);
	
	/**
	 * 获取属于指定会员等级的客户数量
	 * @param membershipId
	 * @return
	 */
	public Integer getCustomerCountsByMembershipId(Integer membershipId);

	/**
	 * 新增客户
	 * @param model
	 * @param status
	 * @return
	 */
	public Customer addCustomer(CustomerFullyModel model, Short status);
	/**
	 * 修改客户
	 * @param customer
	 * @param status
	 * @return
	 */
	public Customer saveFully(CustomerFullyModel model);
	
	/**
	 * 客户导入保存，只用于导入
	 * @param customer
	 * @return
	 */
	public Customer saveFullyForImport(Customer customer);
	/**
	 * 前台注册客户
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public Map<String,Object> doRegisterCustomer(CustomerFullyModel model) throws Exception;
	/**
	 * 逻辑删除客户，
	 * @param customer
	 */
	public void deleteFully(Customer customer);
	/**
	 * 发送验证邮件
	 * @param email
	 */
	public void sendValidationMail(String email);
	
	/**
	 * 激活客户
	 * @param customer
	 */
	public void doActiveCustomer(Customer customer);
	/**
	 * 禁用客户
	 * @param customer
	 */
	public void doForbidCustomer(Customer customer);

	/**
	 * 保存用户选择语言
	 * @param customerId
	 * @param preferredLanguage
	 */
	public void saveCustomerPreferredLanguage(Integer customerId,String preferredLanguage);
	
	
	/**
	  * 
	  * 分页获取所有前台用户的邮件列表（消息订阅）,排除在消息组中的订阅者email
	  * @param pageNo
	  * @param pageSize
	  * @param newsletterGroupIds
	  * @return
	  * 
	  * @author pengzhirong
	  * @since V3.5
	  */
	public List<String> searchCustomerEmails(int pageNo, int pageSize, List<String> newsletterGroupIds);
	
	/**
	 * 邮件激活
	 */
	public void saveAppUserStatusByEmail(String email, Short status);
	 

	// for Eai
	public List<Customer> findExportCustomer(Date lastExecuteTime);

	public void doImportCustomersForEai(List<com.probiz.estore.eai.customer.generated.Customer> customerList);
	
	/**
	 * 统计客户总量-后台控制面板
	 * @return
	 * @since V3.5
	 */
	public Long countCustomerTotal();
	
	/**
	 * 用于更新membershipLevel
	 * @param sc
	 * @return
	 */
	public List<Customer> searchByCriteria4MembershipLevel(SearchCriteria sc);
	/**
	 * 获得所以未删除状态的数据，导出时用到
	 * @return
	 */
	public List<Customer> getListByDeleted() ;
	
	/**
	 * 获得客户，登录用
	 * @param username
	 * @param password
	 * @return
	 */
	public Customer getCustomer4Login(String username, String password);

}
